/*
 * CLivingObject.cpp
 *
 *  Created on: 26.04.2009
 *      Author: markus
 */

#include "CLivingObject.h"

CLivingObject::CLivingObject() : CBaseObject()
{
	m_realMoveConst = 250.0;
	m_realRotConst = 0.1;
	m_scnodPlayerNode = NULL;
	m_v3Direction = Ogre::Vector3::ZERO;
	m_v3Position = Ogre::Vector3::ZERO;
	m_eInvertMouse = INV_FALSE;
	m_realSprintConst = 1.0;
}

CLivingObject::~CLivingObject()
{

}

bool CLivingObject::setMoveConst(float fMoveConst)
{
	m_realMoveConst = Ogre::Real(fMoveConst);
	return true;
}

bool CLivingObject::getRotationConst(float *pfRotConst)
{
	if(pfRotConst == NULL)
	{
		writeDebugOutput("CLivingObject::getRotationConst(): Some pointers are not allocated! Aborting!");
		return false;
	}

	*pfRotConst = (float)m_realRotConst;

	return true;
}

bool CLivingObject::setRotationConst(float fRotConst)
{
	m_realRotConst = Ogre::Real(fRotConst);

	return true;
}

bool CLivingObject::MoveX(float fX)
{
	m_v3Position.x += fX * (float)(m_realMoveConst);
	return true;
}

bool CLivingObject::MoveY(float fY)
{
	m_v3Position.y += fY * (float)(m_realMoveConst);
	return true;
}

bool CLivingObject::MoveZ(float fZ)
{
	m_v3Position.z += fZ * (float)(m_realMoveConst);
	return true;
}

bool CLivingObject::Rotate(float fX, float fY, float fZ)
{
	m_scnodPlayerNode->yaw(Ogre::Degree(-fX * (float)m_realRotConst), Ogre::Node::TS_WORLD);
	m_scnodPlayerNode->pitch(Ogre::Degree(m_eInvertMouse * fY * (float)m_realRotConst), Ogre::Node::TS_LOCAL);

	return true;
}

bool CLivingObject::getMoveConst(float *pfMoveConst)
{
	if(pfMoveConst == NULL)
	{
		writeDebugOutput("CLivingObject::getMoveConst(): Some pointers are not allocated! Aborting!");
		return false;
	}

	*pfMoveConst = (float)m_realMoveConst;
	return true;
}

void CLivingObject::setSprintMove(bool bSprintMove)
{
	if(bSprintMove)
	{
		m_realSprintConst = 3.0;
	}
	else
	{
		m_realSprintConst = 1.0;
	}

//	if(bSprintMove)
//	{
//		m_v3Position *= m_realSprintConst;
//	}
//	else
//	{
//		m_v3Position /= m_realSprintConst;
//	}

	return;
}

Ogre::Real CLivingObject::getSprintMove()
{
	return m_realSprintConst;
}
